<?php

namespace Biz\service\advertisement\apiModule;

use Doraemon\model\AdmCarouselBanner;
use Doraemon\tools\BlockType;
use Doraemon\tools\ImgUrl;

class EvaluationCarouselBanner extends BaseModule
{
    const FORMAT_HIT = 'formatCarouselHit';

    public function format($hits, $uid, $userProfileExt, $statSignExt)
    {
        $banner = [];
        if ($hits) {
            foreach ($hits as $hit) {
                $banner[] = [
                    'id' => (int) $hit['id'],
                    'index' => 0,
                    'link' => $this->generateLink($hit['link_type'], $hit['link_params']),
                    'banner' => strlen($hit['pic_id']) ? ImgUrl::getUrl(ImgUrl::APPTYPE_OP, $hit['pic_id'], ImgUrl::IMAGE_SIZE_OP_ORI) : '',
                    'statType' => 'banner' . BlockType::TYPE_CAROUSEL_BANNER . '-' . AdmCarouselBanner::SHOW_TYPE_EVALUATION_BAMMER,
                    'statSign' => $this->statSign($hit, $statSignExt),
                ];
            }
        }

        return [
            'type' => \Doraemon\tools\BlockType::TYPE_CAROUSEL_BANNER,
            'banner_list' => $banner,
        ];
    }

}